package com.bdqn.service;

import com.bdqn.mapper.SysUserMapper;
import com.bdqn.pojo.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* SysUserService服务层实现类
*/
@Transactional
@Service("sysUserService")
public class SysUserServiceImpl implements SysUserService {

    @Autowired // @Resource // 使用注解的方式将DAO层的Bean注入
    private SysUserMapper sysUserMapper;

    /**
     * 获得用户列表
     *
     * @param sysUser
     * @return
     */
    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public List<SysUser> getList(SysUser sysUser) {
        return sysUserMapper.selectSysUserList(sysUser);
    }

    /**
     * 保存用户
     *
     * @param sysUser
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public boolean add(SysUser sysUser) {
        return sysUserMapper.add(sysUser) == 1;
    }
}
